package com.lele.org.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.lele.org.entity.User;
import com.lele.org.service.HelloService;

@RestController
public class HelloController implements HelloService{
 
    Logger logger = LoggerFactory.getLogger(HelloController.class);
 
    @Autowired
    DiscoveryClient discoveryClient;
 
    @GetMapping("/hello")
    public String hello() {
        ServiceInstance instance = discoveryClient.getLocalServiceInstance();
        //打印服务的服务id
        logger.info("*********" + instance.getServiceId());
        return "hello,this is hello-service";
    }

    @Override
    public String hello2() {
        return "hello,this is hello2-service";
 
    }
 
    @Override
    public User printUser(@RequestBody User user) {
        return user;
    }
}